//
//  NFDescribeViewCell.m
//  PhotoBrowser
//
//  Created by A_Dirt on 16/5/25.
//  Copyright © 2016年 程印. All rights reserved.
//

#define SCREEN_HEIGHT                   [[UIScreen mainScreen] bounds].size.height
//width of window when equipment vertical screen
#define SCREEN_WIDTH                    [[UIScreen mainScreen] bounds].size.width

#import "NFDescribeViewCell.h"
#import "UIView+SDAutoLayout.h"

@implementation NFDescribeViewCell
{
    UILabel * titleLab;
    
    UILabel * pageLab;
    
    UILabel * content;

}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        
        UIView * bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
        bgView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
        [self addSubview:bgView];
        
        [self initUI];
    }

    return self;
}

- (void)initUI
{
    titleLab = [[UILabel alloc] init];
    titleLab.font = [UIFont systemFontOfSize:16];
    titleLab.textColor = [UIColor whiteColor];
    titleLab.textAlignment = NSTextAlignmentLeft;
    titleLab.text = [NSString stringWithFormat:@"深圳一超市扶梯塌陷"];
    titleLab.frame = CGRectMake(15, 0, SCREEN_WIDTH - 100, 30);
    [self addSubview:titleLab];
    
    
    pageLab = [[UILabel alloc] init];
    pageLab.font = [UIFont systemFontOfSize:14];
    pageLab.textColor = [UIColor whiteColor];
    pageLab.textAlignment = NSTextAlignmentRight;
    pageLab.text = [NSString stringWithFormat:@"3/6"];
    pageLab.frame = CGRectMake(SCREEN_WIDTH -  65, 0, 50, 30);
    [self addSubview:pageLab];
    
    content = [[UILabel alloc] init];
    content.font = [UIFont systemFontOfSize:14];
    content.textColor = [UIColor whiteColor];
    content.textAlignment = NSTextAlignmentLeft;
    [self addSubview:content];
    
    content.sd_layout
    .leftSpaceToView(self,15)
    .rightSpaceToView(self,15)
    .topSpaceToView(titleLab,5)
    .autoHeightRatio(0);

}

- (void)showViewEntity:(NFNewsEntity *)entity page:(NSString *)page
{
    content.text = entity.newsContent;
    titleLab.text = entity.newsName;
     pageLab.text = page;

}

+ (CGFloat)commentsHeight: (NSString *)conten
{
    UILabel *lab = [[UILabel alloc] initWithFrame:CGRectZero];
    [lab setNumberOfLines:0];
    lab.font = [UIFont systemFontOfSize:14];
    lab.frame = CGRectMake(0, 21, SCREEN_WIDTH - 30, 0);
    lab.text = conten;
    [lab sizeToFit];
    
    return lab.bounds.size.height;
    
}

@end










